package edu.zut.pojo;

import com.sun.istack.internal.NotNull;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.*;
import java.time.LocalDate;
import java.util.List;

public class UserInfo {
    //@NotBlank : 不为null或‘’
    @NotBlank(message = "用户名不能为空")
    @Size(min = 2,max = 15,message = "长度2~15")
    private String username;

    @NotBlank(message = "密码不能为空")
    @Size(min = 6,max = 10,message = "长度要求是6~10")
    private String password;
    //验证email
    @Email(message = "邮箱格式错误",regexp = "^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\\.[a-zA-Z0-9-]+)*\\.[a-zA-Z0-9]{2,6}$")
    private String email;

    @Min(value = 0)
    @Max(value = 150)
    private Integer age;
    private String sex;
    private List<String> habit;

    //String 转 LocalDate
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @Past
    private LocalDate birthday;

    @Override
    public String toString() {
        return "UserInfo{" +
                "username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", email='" + email + '\'' +
                ", age=" + age +
                ", sex='" + sex + '\'' +
                ", habit=" + habit +
                ", birthday=" + birthday +
                '}';
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public List<String> getHabit() {
        return habit;
    }

    public void setHabit(List<String> habit) {
        this.habit = habit;
    }

    public LocalDate getBirthday() {
        return birthday;
    }

    public void setBirthday(LocalDate birthday) {
        this.birthday = birthday;
    }
}
